package com.neusoft.nep.SystemAdminstrator.Controller;

import com.neusoft.nep.SystemAdminstrator.Common.AlertUtills;
import com.neusoft.nep.SystemAdminstrator.Common.FileUtills;
import com.neusoft.nep.SystemAdminstrator.entity.SystemFeedback;
import com.neusoft.nep.entity.Feedback;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class publicListController {

    AlertUtills alertUtills = new AlertUtills();

    private static Map<String, SystemFeedback> convertToSystemMap(Map<String, Feedback> feedbackMap) {
        Map<String, SystemFeedback> systemFeedbackMap = FileUtills.readMapObject("SystemFeedback.txt");
        for (Map.Entry<String, Feedback> entry : feedbackMap.entrySet()) {
            String key = entry.getKey();
            Feedback feedback = entry.getValue();

            // 检查系统反馈映射中是否存在该键
            SystemFeedback systemFeedback = systemFeedbackMap.get(key);

            // 如果不存在，创建新的SystemFeedback对象
            if (systemFeedback == null) {
                systemFeedback = new SystemFeedback(feedback.getIndex(),feedback.getProvince(),feedback.getName(),feedback.getSex(),feedback.getName(),feedback.getBirthday(),feedback.getCity(),feedback.getAddress(),feedback.getAqiLevel(),feedback.getDescription(),feedback.getTime());
                // 这里不需要设置独有属性，因为新对象的独有属性应该保持默认值
                systemFeedbackMap.put(key, systemFeedback);
            }

            systemFeedback.setAqiLevel(feedback.getAqiLevel());
            systemFeedback.setAddress(feedback.getAddress());
            systemFeedback.setIndex(feedback.getIndex());
            systemFeedback.setName(feedback.getName());
            systemFeedback.setSex(feedback.getSex());
            systemFeedback.setProvince(feedback.getProvince());
            systemFeedback.setCity(feedback.getCity());
            systemFeedback.setDescription(feedback.getDescription());
            systemFeedback.setPhoneNumber(feedback.getPhoneNumber());
            systemFeedback.setBirthday(feedback.getBirthday());
            systemFeedback.setTime(feedback.getTime());

//            for (Map.Entry<String,SystemFeedback> entry1: systemFeedbackMap.entrySet()){
//                String SFkey = entry1.getKey();
//                SystemFeedback systemFeedback = entry1.getValue();
//            }
        }
        return systemFeedbackMap;
    }
    @FXML
    private Button btn_clear;
    @FXML
    private Button btn_query;

    public void query(ActionEvent event) {
        // 获取用户选择的过滤条件
        String selectedProvince = comProv.getSelectionModel().getSelectedItem();
        String selectedCity = comCity.getSelectionModel().getSelectedItem();
        String selectedLevel = comLexel.getSelectionModel().getSelectedItem();
        LocalDate selectedDate = datePicker.getValue();

        // 获取所有数据
        Map<String, Feedback> feedbackmap = FileUtills.readMapObject("feedback.txt");
        Map<String, SystemFeedback> systemFeedbackMap = convertToSystemMap(feedbackmap);
        ObservableList<SystemFeedback> allData = FXCollections.observableArrayList(systemFeedbackMap.values());

//        System.out.println(systemFeedbackMap.get(1).getIndex());
        // 根据过滤条件筛选数据
        ObservableList<SystemFeedback> filteredData = FXCollections.observableArrayList();
        for (SystemFeedback feedback : allData) {
            boolean provinceMatch = selectedProvince == null || feedback.getProvince().equals(selectedProvince);
            boolean cityMatch = selectedCity == null || feedback.getCity().equals(selectedCity);
            boolean levelMatch = selectedLevel == null || feedback.getAqiLevel().equals(selectedLevel);
            boolean dateMatch = selectedDate == null || feedback.getDate().equals(selectedDate);

            if (provinceMatch && cityMatch && levelMatch && dateMatch) {
                filteredData.add(feedback);
            }
        }

        // 更新表格中的数据
        systemFeedbackTableView.setItems(filteredData);
    }

    public void Clear(ActionEvent event){
        comProv.getSelectionModel().clearSelection();
        comCity.getSelectionModel().clearSelection();
        comLexel.getSelectionModel().clearSelection();
        comProv.requestLayout();
        datePicker.setValue(LocalDate.now());
        comProv.setPromptText("请输入");
        comCity.setPromptText("请输入");
        comLexel.setPromptText("请输入");
    }
    @FXML
    private RadioButton rolAssign,rolunAssign;//创建两个选择按钮并与fxml绑定
    @FXML
    private ToggleGroup toggleGroup;//创建一个单选按钮组，toggle_单选
    @FXML
    private ComboBox<String> comProv,comCity,comLexel;
    @FXML
    private TableView<SystemFeedback> systemFeedbackTableView;
    @FXML
    private TableColumn<SystemFeedback,Integer> colID;
    @FXML
    private TableColumn<SystemFeedback,String> colname;
    @FXML
    private TableColumn<SystemFeedback,String> colprovince;
    @FXML
    private TableColumn<SystemFeedback,String> colcity;
    @FXML
    private TableColumn<SystemFeedback,String> collexel;
    @FXML
    private TableColumn<SystemFeedback,LocalDate> coldate;
    @FXML
    private TableColumn<SystemFeedback,LocalTime> coltimepart;
    @FXML
    private TableColumn<SystemFeedback,Void> coldetail;
    @FXML
    private TableColumn<SystemFeedback,Void> colassign;
    @FXML
    private DatePicker datePicker;

    private ObservableList<SystemFeedback> tablelist = FXCollections.observableArrayList();

    Map<String,List<String>> provinceMap = new HashMap<>();
    Map<String,List<String>> cityMap = new HashMap<>();

    public void unAssign(ActionEvent event){
        tablelist.clear();

        btn_query.setOnAction(this::query);

        datePicker.setValue(LocalDate.now());

        //给每一列都绑定上相应的systemfeedback的可视化属性
        colID.setCellValueFactory(new PropertyValueFactory<>("index"));
        colname.setCellValueFactory(new PropertyValueFactory<>("name"));
        colprovince.setCellValueFactory(new PropertyValueFactory<>("province"));
        collexel.setCellValueFactory(new PropertyValueFactory<>("aqiLevel"));
        colcity.setCellValueFactory(new PropertyValueFactory<>("city"));
        coldate.setCellValueFactory(new PropertyValueFactory<>("date"));
        coltimepart.setCellValueFactory(new PropertyValueFactory<>("timePart"));

        Map<String,SystemFeedback> TrueSystemFeedback = FileUtills.readMapObject("SystemFeedback.txt");

        // 筛选未指派的对象
        for (SystemFeedback feedback : TrueSystemFeedback.values()) {
            if (!feedback.getAssigned()) {
                tablelist.add(feedback);
            }
        }

        //把列表的数据导入表格
        systemFeedbackTableView.setItems(tablelist);
        //写动态按钮，也就是详情和指派
        //设置单元格内容
        coldetail.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("详情");//创建一个按钮
            {//设置onAction
                btn.setOnAction(e -> {
                    //获取当前行的那个systemfeedback对象
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    FXMLLoader fxmlLoader = new FXMLLoader();
                    URL url = getClass().getResource("../View/feedbackinfo.fxml");
                    fxmlLoader.setLocation(url);
                    Parent root = null;
                    try {
                        root = fxmlLoader.load();
                    } catch (IOException ex) {
                        throw new RuntimeException(ex);
                    }
                    //要记住，不管是什么控制器，本质上它还是一个java类，是类就能创建实例然后调用方法
                    FeedbackinfoController feedbackinfoController = fxmlLoader.getController();
                    feedbackinfoController.setSystemFeedback(systemFeedback);
                    Scene scene = btn.getScene();
                    scene.setRoot(root);
                    Stage stage = (Stage) scene.getWindow();
                    stage.show();
                });
            }
            //用来实时更新并显示按钮
            @Override
            protected void updateItem(Void item, boolean emtiy){
                super.updateItem(item, emtiy);
                setGraphic(emtiy? null : btn);
            }
        });
        colassign.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("指派");
            {
                btn.setOnAction(e->{
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    if (!systemFeedback.getAssigned()) {
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    } else {
                        alertUtills.Showdialog("指派",null,"已经指派过了\n是否重新指派？");
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    }
                });
            }
            //用来实时更新并显示按钮
            @Override
            protected void updateItem(Void item, boolean emtiy){
                super.updateItem(item, emtiy);
                setGraphic(emtiy? null : btn);
            }
        });
    }

    public void Assign(ActionEvent event){
        tablelist.clear();

        btn_query.setOnAction(this::query);

        datePicker.setValue(LocalDate.now());

        //给每一列都绑定上相应的systemfeedback的可视化属性
        colID.setCellValueFactory(new PropertyValueFactory<>("index"));
        colname.setCellValueFactory(new PropertyValueFactory<>("name"));
        colprovince.setCellValueFactory(new PropertyValueFactory<>("province"));
        collexel.setCellValueFactory(new PropertyValueFactory<>("aqiLevel"));
        colcity.setCellValueFactory(new PropertyValueFactory<>("city"));
        coldate.setCellValueFactory(new PropertyValueFactory<>("date"));
        coltimepart.setCellValueFactory(new PropertyValueFactory<>("timePart"));

        Map<String,SystemFeedback> TrueSystemFeedback = FileUtills.readMapObject("SystemFeedback.txt");

        // 筛选未指派的对象
        for (SystemFeedback feedback : TrueSystemFeedback.values()) {
            if (feedback.getAssigned()) {
                tablelist.add(feedback);
            }
        }

        //把列表的数据导入表格
        systemFeedbackTableView.setItems(tablelist);
        //写动态按钮，也就是详情和指派
        //设置单元格内容
        coldetail.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("详情");//创建一个按钮
            {//设置onAction
                btn.setOnAction(e -> {
                    //获取当前行的那个systemfeedback对象
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    FXMLLoader fxmlLoader = new FXMLLoader();
                    URL url = getClass().getResource("../View/feedbackinfo.fxml");
                    fxmlLoader.setLocation(url);
                    Parent root = null;
                    try {
                        root = fxmlLoader.load();
                    } catch (IOException ex) {
                        throw new RuntimeException(ex);
                    }
                    //要记住，不管是什么控制器，本质上它还是一个java类，是类就能创建实例然后调用方法
                    FeedbackinfoController feedbackinfoController = fxmlLoader.getController();
                    feedbackinfoController.setSystemFeedback(systemFeedback);
                    Scene scene = btn.getScene();
                    scene.setRoot(root);
                    Stage stage = (Stage) scene.getWindow();
                    stage.show();
                });
            }
            //用来实时更新并显示按钮
            @Override
            protected void updateItem(Void item, boolean emtiy){
                super.updateItem(item, emtiy);
                setGraphic(emtiy? null : btn);
            }
        });
        colassign.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("指派");
            {
                btn.setOnAction(e->{
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    if (!systemFeedback.getAssigned()) {
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    } else {
                        alertUtills.Showdialog("指派",null,"已经指派过了\n是否重新指派？");
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    }
                });
            }
            //用来实时更新并显示按钮
            @Override
            protected void updateItem(Void item, boolean emtiy){
                super.updateItem(item, emtiy);
                setGraphic(emtiy? null : btn);
            }
        });

    }

    @FXML
    private Label labID;

    public void initialize() throws IOException {
        labID.setText("系统管理员：" + loginController.currentLoginID);

        File file = new File("SystemFeedback.txt");
        file.createNewFile();

        btn_query.setOnAction(this::query);

        datePicker.setValue(LocalDate.now());

        //给每一列都绑定上相应的systemfeedback的可视化属性
        colID.setCellValueFactory(new PropertyValueFactory<>("index"));
        colname.setCellValueFactory(new PropertyValueFactory<>("name"));
        colprovince.setCellValueFactory(new PropertyValueFactory<>("province"));
        collexel.setCellValueFactory(new PropertyValueFactory<>("aqiLevel"));
        colcity.setCellValueFactory(new PropertyValueFactory<>("city"));
        coldate.setCellValueFactory(new PropertyValueFactory<>("date"));
        coltimepart.setCellValueFactory(new PropertyValueFactory<>("timePart"));

        //本地创建一个feedback用于接受读取出来的文件
        Map<String,Feedback> feedbackmap = FileUtills.readMapObject("feedback.txt");
        //通过上方已经写好的类型转化函数来把存feedback类的hashmap转化成存systemfeedback的hashmap
        Map<String,SystemFeedback> systemFeedbackMap = convertToSystemMap(feedbackmap);
        FileUtills.writeMapObject("SystemFeedback.txt",systemFeedbackMap);
        Map<String,SystemFeedback> TrueSystemFeedback = FileUtills.readMapObject("SystemFeedback.txt");




//        tablelist.add(new SystemFeedback(01,"尚书","男","139","1201","辽宁省","大连市","金州区","一","蓝天白云","2025-01-11 11:11:11"));
        tablelist.addAll(TrueSystemFeedback.values());//把hashmap的数据导入列表
        //把列表的数据导入表格
        systemFeedbackTableView.setItems(tablelist);
        //写动态按钮，也就是详情和指派
        //设置单元格内容
        coldetail.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("详情");//创建一个按钮
            {//设置onAction
                btn.setOnAction(e -> {
                    //获取当前行的那个systemfeedback对象
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    FXMLLoader fxmlLoader = new FXMLLoader();
                    URL url = getClass().getResource("../View/feedbackinfo.fxml");
                    fxmlLoader.setLocation(url);
                    Parent root = null;
                    try {
                        root = fxmlLoader.load();
                    } catch (IOException ex) {
                        throw new RuntimeException(ex);
                    }
                    //要记住，不管是什么控制器，本质上它还是一个java类，是类就能创建实例然后调用方法
                    FeedbackinfoController feedbackinfoController = fxmlLoader.getController();
                    feedbackinfoController.setSystemFeedback(systemFeedback);
                    Scene scene = btn.getScene();
                    scene.setRoot(root);
                    Stage stage = (Stage) scene.getWindow();
                    stage.show();
                });
            }
            //用来实时更新并显示按钮
            @Override
            protected void updateItem(Void item,boolean emtiy){
                super.updateItem(item,emtiy);
                setGraphic(emtiy?null:btn);
            }
        });
        colassign.setCellFactory(cols->new TableCell<>(){
            private Button btn = new Button("指派");
            {
                btn.setOnAction(e->{
                    SystemFeedback systemFeedback = getTableView().getItems().get(getIndex());
                    if (!systemFeedback.getAssigned()) {
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    }else {
                        alertUtills.Showdialog("指派",null,"已经指派过了\n是否重新指派？");
                        FXMLLoader fxmlLoader = new FXMLLoader();
                        URL url = getClass().getResource("../View/PublicDataAssign.fxml");
                        fxmlLoader.setLocation(url);
                        Parent root = null;
                        try {
                            root = fxmlLoader.load();
                        } catch (IOException ex) {
                            throw new RuntimeException(ex);
                        }
                        PublicDataAssignController publicDataAssignController = fxmlLoader.getController();
                        publicDataAssignController.setSystemFeedback(systemFeedback);
                        Scene scene = btn.getScene();
                        scene.setRoot(root);
                        Stage stage = (Stage) scene.getWindow();
                        stage.show();
                    }
                });
            }

            @Override
            protected void updateItem(Void item, boolean empty) {
                super.updateItem(item, empty);
                setGraphic(empty?null:btn);
            }
        });

        toggleGroup = new ToggleGroup();//两个rol是与fxml中实际的按钮绑定用的，但是togglegroup不是，它是原汁原味的类属性，需要初始化也就是创建具体对象
        rolAssign.setToggleGroup(toggleGroup);//放进去
        rolunAssign.setToggleGroup(toggleGroup);//两个按钮放进一个单选按钮组，因为单选按钮组的特性，只许选一个
        //把具体省市以及污染等级的信息录入
        provinceMap.put("辽宁省",List.of("沈阳市","大连市"));
        provinceMap.put("吉林省",List.of("长春市","吉林市"));
        provinceMap.put("黑龙江省",List.of("哈尔滨市","齐齐哈尔市"));

        cityMap.put("沈阳市",List.of("一","二","三","四","五","六"));
        cityMap.put("大连市",List.of("一","二","三","四","五","六"));
        cityMap.put("长春市",List.of("一","二","三","四","五","六"));
        cityMap.put("吉林市",List.of("一","二","三","四","五","六"));
        cityMap.put("哈尔滨市",List.of("一","二","三","四","五","六"));
        cityMap.put("齐齐哈尔市",List.of("一","二","三","四","五","六"));
        //
        comProv.setItems(FXCollections.observableArrayList(provinceMap.keySet()));//为省的下拉列表创建一个可视化类，并把先前录入好的省信息放进去
        comProv.getSelectionModel().clearSelection();//点击省的下拉列表之后，获取点击的那个列表来清除上次的选择信息
        comProv.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {//得到刚才点击的那个列表，然后选择相应的属性并添加监视器

            @Override
            public void changed(ObservableValue<? extends String> observableValue, String oldValue, String newValue) {
                //三个形参，
                //分别是一个用于重写方法的接口，
                //一个旧的准备拿来被替换的可视化数据，
                //一个新的准备拿来换掉旧的可视化数据
                List<String> citys = provinceMap.getOrDefault(newValue,List.of());//创建一个新数据的list用于接受传参
                comCity.setItems(FXCollections.observableArrayList(citys));//根据新信息创建新的视图
                comCity.setPromptText("请选择");
                comCity.getSelectionModel().clearSelection();//清空城市下拉列表的旧选择
                comLexel.getItems().clear();//清空污染等级的旧选择
            }
        });
        comCity.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            //再来一遍
            @Override
            public void changed(ObservableValue<? extends String> observableValue, String oldValue, String newValue) {
                List<String> lexels = cityMap.getOrDefault(newValue,List.of());
                comLexel.setItems(FXCollections.observableArrayList(lexels));
                comLexel.setPromptText("请选择");
                comLexel.getSelectionModel().clearSelection();
            }
        });
    }


    @FXML
    private Button btn_out;
    public void OUT(ActionEvent actionEvent){
        System.exit(0);
    }
    @FXML
    private MenuItem mi_PSL;
    public void  PSLClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/publicList.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
    @FXML
    private MenuItem mi_AQI;
    public void  AQIListClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/AQImakesure.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
    @FXML
    private MenuItem mi_PGC;
    public void PGCClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/ProvincialGroupComponentItemInspectionStatistics.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
    @FXML
    private MenuItem mi_AqiDistribute;
    public void AqiDistributeClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/AqiDistributeTotalStatisView.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
    @FXML
    private MenuItem mi_Other;
    public void OtherClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/OtherTotalStatisView.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
    @FXML
    private MenuItem mi_AqiTrendTotal;
    public void AqiTrendClick(ActionEvent event) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = getClass().getResource("../View/AqiTrendTotalStatisView.fxml");
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = btn_out.getScene();
        scene.setRoot(root);
        Stage stage = (Stage) scene.getWindow();
        stage.show();
    }
}
